package com.hckjsec.oa.controller;

import com.alibaba.fastjson.JSON;
import com.hckjsec.common.annotation.RepeatSubmit;
import com.hckjsec.common.constant.Constants;
import com.hckjsec.common.core.controller.BaseController;
import com.hckjsec.common.core.domain.AjaxResult;
import com.hckjsec.common.core.domain.entity.SysDictData;
import com.hckjsec.common.core.domain.entity.SysUser;
import com.hckjsec.common.core.redis.RedisCache;
import com.hckjsec.common.core.redis.SerialNumberUtils;
import com.hckjsec.common.enums.NumbereEnum;
import com.hckjsec.common.enums.UserStatus;
import com.hckjsec.common.exception.BaseException;
import com.hckjsec.common.general.ListStringView;
import com.hckjsec.common.holiday.HolidayUtil;
import com.hckjsec.common.utils.*;
import com.hckjsec.framework.aspectj.DataScopeAspect;
import com.hckjsec.oa.domain.*;
import com.hckjsec.oa.domain.OaView.*;
import com.hckjsec.oa.flow.FlowPath;
import com.hckjsec.oa.service.*;
import com.hckjsec.system.domain.SysNotice;
import com.hckjsec.system.domain.SysPost;
import com.hckjsec.system.domain.SysUserOnline;
import com.hckjsec.system.service.ISysDictTypeService;
import com.hckjsec.system.service.ISysNoticeService;
import com.hckjsec.system.service.ISysPostService;
import com.hckjsec.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.web.bind.annotation.*;

import java.text.DecimalFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;

/**
 * 此类处理公司OA手机端请求的接口数据
 */
@RestController
@RequestMapping("/oa/api")
public class AppOaPublicApiController extends BaseController {
    @Autowired
    private ISysUserService userService;
    @Autowired
    private RedisCache redisCache;
    @Autowired
    private IOaConfigService oaConfigService;
    @Autowired
    private IOaAttendanceService oaAttendanceService;
    @Autowired
    private IOaDateService oaDateService;
    @Autowired
    private IOaApplyService oaApplyService;
    @Autowired
    private IOaLeaveService oaLeaveService;
    @Autowired
    private IOaMissionService oaMissionService;
    @Autowired
    private ISysDictTypeService dictTypeService;
    @Autowired
    private IOaExpenseService oaExpenseService;
    @Autowired
    private IOaClientService oaClientService;
    @Autowired
    private IOaContractService oaContractService;
    @Autowired
    private ISysPostService postService;
    @Autowired
    private IOaAuditingService oaAuditingService;
    @Autowired
    private ISysNoticeService noticeService;
    /**
     * 公司OA登录
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/login")
//    @RepeatSubmit
    public AjaxResult login(@RequestBody AppRequestView appRequestView,@RequestParam(name = "deviceId") String deviceId) {
        AppUserView appUserView = new AppUserView();
        String username = StringUtils.isHcNull(appRequestView.getUsername(), "");
        String password = StringUtils.isHcNull(appRequestView.getPassword(), "");
        if ("".equals(username) || "".equals(password)) {
            return AjaxResult.cloud_602("用户名或密码不能为空");
        }
        SysUser user = userService.selectUserByUserName(username);
        if (StringUtils.isNull(user))
        {
            return AjaxResult.cloud_602(StringUtils.format("登录用户：{} 不存在.", username));
        }
        else if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
        {
            return AjaxResult.cloud_602(StringUtils.format("登录用户：{} 已被删除.", username));
        }
        else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
        {
            return AjaxResult.cloud_602(StringUtils.format("登录用户：{} 已被停用.", username));
        }
        if (!SecurityUtils.matchesPassword(password,user.getPassword())){
            return AjaxResult.cloud_602(StringUtils.format("登录用户：{} 密码错误.", username));
        }
        //第一次绑定设备id
        String equipmentId = StringUtils.isHcNull(user.getEquipmentId(), "");
        if ("".equals(equipmentId)){
            int rows = userService.updateUserEquipmentId(deviceId,user.getUserId());
            if (rows > 0){
                user.setEquipmentId(deviceId);
            }
        }else{
            if (!deviceId.trim().equals(equipmentId.trim())){
                return AjaxResult.cloud_602(StringUtils.format("登录用户：{} 设备id错误，请联系人事部刘经理处理.", username));
            }
        }
        String idStr = String.valueOf(user.getUserId());
        Collection<String> keys = redisCache.keys(Constants.APP_USER_TOKEN + "*");
        for (String key : keys){
            String keyStr = key.replace(Constants.APP_USER_TOKEN, "").trim();
            if (idStr.equals(WebDecodeUtil.Decrypt(keyStr))){
                redisCache.deleteObject(key);
            }
        }
        String  token = WebDecodeUtil.Encrypt(idStr);
        appUserView.setToken(token);
        appUserView.setUser(user);
        redisCache.setCacheObject(ComUtil.getOaCacheKey(token),appUserView);
        return AjaxResult.success(appUserView);
    }

    /**
     * 公司OA获取打卡信息
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getClockData")
    public AjaxResult getClockData(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        OaConfig oaConfig = new OaConfig();
        List<OaConfig> list = oaConfigService.selectOaConfigList(null);
        if (!StringUtils.isEmpty(list)){
            oaConfig = list.get(0);
        }
        AppClockView appClockView = new AppClockView(oaConfig.getPlace(),oaConfig.getStartWorkTime(),oaConfig.getEndWorkTime(),oaConfig.getLongitude(),oaConfig.getLatitude());
        //计算距离打开位置距离
        double distance = DistanceCalculation.isTrue(appRequestView.getLongitude(),appRequestView.getLatitude(),oaConfig.getLongitude(),oaConfig.getLatitude());
        appClockView.setDistance(distance+" km");
        return AjaxResult.success(appClockView);
    }


    /**
     * 公司OA签到
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/signIn")
//    @RepeatSubmit
    public AjaxResult signIn(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        String type = StringUtils.isHcNull(appRequestView.getType(), "");//0-内勤   1-外勤
        Date nowDate = DateUtils.getNowDate();//当前时间
        if ("".equals(type)){
            return AjaxResult.cloud_602("打卡类型不能为空!");
        }
        String   date =  DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate());//当前时间
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        //1.查询用户是否签到
        OaAttendance oaAttendance = new OaAttendance();
        oaAttendance.setUserId(appUserView.getUser().getUserId());
        oaAttendance.setDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,date));
        oaAttendance.setPeriod("0");
        List<OaAttendance> list = oaAttendanceService.selectOaAttendanceList(oaAttendance);
        if (!StringUtils.isEmpty(list)){
            return AjaxResult.cloud_602("请勿重复签到!");
        }
        OaConfig oaConfig = new OaConfig();
        List<OaConfig> configList = oaConfigService.selectOaConfigList(null);
        if (!StringUtils.isEmpty(configList)){
            oaConfig = configList.get(0);
        }
        //2.查询签到距离是否在误差值范围内 如为内勤
        String  state = "0";
        String exceedMsg = "正常";
        long interval = 0L;
        if ("0".equals(type)){
            System.out.println("传入经纬度："+appRequestView.getLongitude()+"========="+appRequestView.getLatitude());
            System.out.println("设置经纬度："+oaConfig.getLongitude()+"========="+oaConfig.getLatitude());
            double distance = DistanceCalculation.isTrue(appRequestView.getLongitude(),appRequestView.getLatitude(),oaConfig.getLongitude(),oaConfig.getLatitude());
            double meter = distance*1000;
            System.out.println("距离："+meter);
            double errorValue = Double.valueOf(oaConfig.getErrorValue());
            System.out.println("误差："+errorValue);
            if (meter > errorValue){
                return AjaxResult.cloud_602("不在考勤范围内!");
            }
            String oldDateStr = date+" "+oaConfig.getStartWorkTime()+":00";
            Date oldDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,oldDateStr);//打卡时间
            interval = (oldDate.getTime() - nowDate.getTime())/1000;
            if (interval < 0){//说明迟到
                state = "1";
                exceedMsg = "迟到："+DateUtils.getIntervalStr(interval);
            }else{
                interval = 0L;
            }
        }
        OaAttendance findOaAttendance = new OaAttendance();
        findOaAttendance.setDeptId(appUserView.getUser().getDeptId());
        findOaAttendance.setUserId(appUserView.getUser().getUserId());
        findOaAttendance.setUserName(appUserView.getUser().getNickName());
        findOaAttendance.setDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,date));
        findOaAttendance.setAttendanceType(type);
        findOaAttendance.setPeriod("0");
        findOaAttendance.setPthTime(nowDate);
        findOaAttendance.setAddress(appRequestView.getAddress());
        findOaAttendance.setState(state);
        findOaAttendance.setExceed(Math.abs(interval));
        findOaAttendance.setExceedMsg(exceedMsg);
        findOaAttendance.setAttendanceImg(StringUtils.join(appRequestView.getAttendanceImg(), ","));
        findOaAttendance.setContent(appRequestView.getContent());
        findOaAttendance.setCreateTime(nowDate);
        return toAjax(oaAttendanceService.insertOaAttendance(findOaAttendance));
    }

    /**
     * 公司OA签退
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/signOut")
//    @RepeatSubmit
    public AjaxResult signOut(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        String type = StringUtils.isHcNull(appRequestView.getType(), "");//0-内勤   1-外勤
        Date nowDate = DateUtils.getNowDate();//当前时间
        if ("".equals(type)){
            return AjaxResult.cloud_602("打卡类型不能为空");
        }
        String   date =  DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate());//当前时间
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        //1.查询用户是否签退
        OaAttendance oaAttendance = new OaAttendance();
        oaAttendance.setUserId(appUserView.getUser().getUserId());
        oaAttendance.setDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,date));
        oaAttendance.setPeriod("0");
        List<OaAttendance> list = oaAttendanceService.selectOaAttendanceList(oaAttendance);
        if (StringUtils.isEmpty(list)){
            return AjaxResult.cloud_602("请先签到!");
        }
        oaAttendance.setPeriod("1");
        List<OaAttendance> delList = oaAttendanceService.selectOaAttendanceList(oaAttendance);
        Long delId = 0L;
        if (!StringUtils.isEmpty(delList)){
            delId = delList.get(0).getId();
        }
        OaConfig oaConfig = new OaConfig();
        List<OaConfig> configList = oaConfigService.selectOaConfigList(null);
        if (!StringUtils.isEmpty(configList)){
            oaConfig = configList.get(0);
        }
        //2.查询签到距离是否在误差值范围内 如为内勤
        String  state = "0";
        String exceedMsg = "正常";
        long interval = 0L;
        if ("0".equals(type)){
            double distance = DistanceCalculation.isTrue(appRequestView.getLongitude(),appRequestView.getLatitude(),oaConfig.getLongitude(),oaConfig.getLatitude());
            double meter = distance*1000;
            double errorValue = Double.valueOf(oaConfig.getErrorValue());
            if (meter > errorValue){
                return AjaxResult.cloud_602("不在考勤范围内!");
            }
            String oldDateStr = date+" "+oaConfig.getEndWorkTime()+":00";
            Date oldDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,oldDateStr);//打卡时间
            interval = (nowDate.getTime() - oldDate.getTime())/1000;
            if (interval < 0){//说明早退
                state = "2";
                exceedMsg = "早退："+DateUtils.getIntervalStr(interval);
            }else{
                interval = 0L;
            }
        }
        OaAttendance findOaAttendance = new OaAttendance();
        findOaAttendance.setDeptId(appUserView.getUser().getDeptId());
        findOaAttendance.setUserId(appUserView.getUser().getUserId());
        findOaAttendance.setUserName(appUserView.getUser().getNickName());
        findOaAttendance.setDate(DateUtils.dateTime(DateUtils.YYYY_MM_DD,date));
        findOaAttendance.setAttendanceType(type);
        findOaAttendance.setPeriod("1");
        findOaAttendance.setPthTime(nowDate);
        findOaAttendance.setAddress(appRequestView.getAddress());
        findOaAttendance.setState(state);
        findOaAttendance.setExceed(Math.abs(interval));
        findOaAttendance.setExceedMsg(exceedMsg);
        findOaAttendance.setAttendanceImg(StringUtils.join(appRequestView.getAttendanceImg(), ","));
        findOaAttendance.setContent(appRequestView.getContent());
        findOaAttendance.setCreateTime(nowDate);
        int rows = oaAttendanceService.insertOaAttendance(findOaAttendance);
        if (rows >0){
            if (delId > 0){
                oaAttendanceService.deleteOaAttendanceById(delId);
            }
        }
        return toAjax(rows);
    }

    /**
     * 公司OA查询两个月数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getSignList")
    public AjaxResult getSignList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        String   startTime =  DateUtils.getPastMonth(1)+"-01";//获取上个月第一天
        //查询员工入职时间
        if (StringUtils.isNotNull(appUserView.getUser().getInductionDate())){
            String rzDate = StringUtils.isHcNull(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,appUserView.getUser().getInductionDate()), "");
            if (DateUtils.compareStrDate(startTime,rzDate,DateUtils.YYYY_MM_DD)){
                startTime = rzDate;
            }
        }
        String   endTim = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,DateUtils.getNowDate());
        OaDate  oaDate = new  OaDate();
        oaDate.setBeginTime(startTime);
        oaDate.setEndTime(endTim);
        List<OaDate> oaDateList = oaDateService.selectOaDateList(oaDate);
        LinkedHashMap<String, CalendarSignView> calendarMap = new LinkedHashMap<>();
        oaDateList.forEach(kv->{
            CalendarSplitView signIn = new CalendarSplitView("0");
            CalendarSplitView signOut = new CalendarSplitView("1");
            String  info = "正常";
            Long festival = kv.getFestival();
            CalendarSignView calendarSignView = new CalendarSignView();
            calendarSignView.setDate(kv.getDate());
            if (festival == 0){//代表需要上班
                info = "异常";
                signIn.setState("-1");
                signOut.setState("-1");
            }else{
                signIn.setState("0");
                signOut.setState("0");
            }
            calendarSignView.setInfo(info);
            calendarSignView.setFestival(festival);
            calendarSignView.setSignIn(signIn);
            calendarSignView.setSignOut(signOut);
            String   date =  DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,kv.getDate());
            calendarMap.put(date,calendarSignView);
        });
        OaAttendance oaAttendance = new  OaAttendance();
        oaAttendance.setBeginTime(startTime);
        oaAttendance.setEndTime(endTim);
        oaAttendance.setUserId(appUserView.getUser().getUserId());
        List<OaAttendance> oaAttendanceList =  oaAttendanceService.selectOaAttendanceList(oaAttendance);
        oaAttendanceList.forEach(kv->{
            String   date =  DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,kv.getDate());
            CalendarSignView calendarSignView = calendarMap.get(date);
            String period = kv.getPeriod();
            if ("0".equals(period)){//签到
                CalendarSplitView oldSignIn = calendarSignView.getSignIn();
                oldSignIn.setAttendanceType(kv.getAttendanceType());
                oldSignIn.setState(kv.getState());
                oldSignIn.setPthTime(kv.getPthTime());
                oldSignIn.setExceedMsg(kv.getExceedMsg());
                calendarSignView.setSignIn(oldSignIn);
            }else if ("1".equals(period)) {//签退
                CalendarSplitView oldSignOut = calendarSignView.getSignOut();
                oldSignOut.setAttendanceType(kv.getAttendanceType());
                oldSignOut.setState(kv.getState());
                oldSignOut.setPthTime(kv.getPthTime());
                oldSignOut.setExceedMsg(kv.getExceedMsg());
                calendarSignView.setSignOut(oldSignOut);
            }
            calendarMap.put(date,calendarSignView);
        });
        List<CalendarFinalSignView>  findList = new ArrayList<>();
        calendarMap.forEach((k,v)->{
            CalendarFinalSignView calendarFinalSignView = new CalendarFinalSignView();
            calendarFinalSignView.setDate(v.getDate());
            calendarFinalSignView.setInfo(v.getInfo());
            List<CalendarSplitView> checkState = new ArrayList<>();
            checkState.add(v.getSignIn());
            checkState.add(v.getSignOut());
            calendarFinalSignView.setCheckState(checkState);
            Long festival = v.getFestival();
            if (festival == 0){
                findList.add(calendarFinalSignView);
            }else{
                //判断下  如果是周六周日和法定节假日   如果没打开  就过滤
                boolean isDk = false;
                if (StringUtils.isNotNull(v.getSignIn().getPthTime()) ||  StringUtils.isNotNull(v.getSignOut().getPthTime())){
                    isDk = true;
                }
                if (isDk){
                    findList.add(calendarFinalSignView);
                }
            }
        });
        return AjaxResult.success(findList);
    }
    /*****************************加班Start***************************************************/
    /**
     * 加班列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getApplyList")
    public AjaxResult getApplyList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaApply oaApply = new OaApply();
        oaApply.getParams().put("authority", DataScopeAspect.getDataScopeSql(appUserView.getUser()));
        List<OaApply> list = oaApplyService.selectOaApplyList(oaApply);
        list.forEach(kv->{
            kv.setDurationStr(DateUtils.getIntervalStr(kv.getDuration()));
        });
        return AjaxResult.success(list);
    }

    /**
     * 判断是否存在加班数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getIsApply")
    public AjaxResult getIsApply(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        String date = StringUtils.isHcNull(appRequestView.getDate(), "");//0-内勤   1-外勤
        if ("".equals(date)){
            return AjaxResult.cloud_602("请求时间不能为空");
        }
        //判断加班是否在指定范围内
        String oldTenDate = DateUtils.getPastDate(11);//获取前10天日期
        boolean flag = DateUtils.compareStrDate(oldTenDate,date,DateUtils.YYYY_MM_DD);
        if (!flag){
            return AjaxResult.cloud_602("日期超出可选范围!");
        }
        Long  userId = appUserView.getUser().getUserId();
        //获取配置
        OaConfig oaConfig = new OaConfig();
        List<OaConfig> configList = oaConfigService.selectOaConfigList(null);
        if (!StringUtils.isEmpty(configList)){
            oaConfig = configList.get(0);
        }
        OaConfig finalOaConfig = oaConfig;
        //获取上月到昨天加班列表
        OaDate oaDate = new  OaDate();
        oaDate.setBeginTime(date);
        oaDate.setEndTime(date);
        List<OaDate> oaDateList = oaDateService.selectOaDateList(oaDate);
        LinkedHashMap<Date, Long> calendarMap = new LinkedHashMap<>();
        oaDateList.forEach(kv->{
            calendarMap.put(kv.getDate(),kv.getFestival());
        });
        OaAttendance findOaAttendance = new  OaAttendance();
        findOaAttendance.setBeginTime(date);
        findOaAttendance.setEndTime(date);
        findOaAttendance.setUserId(userId);
        findOaAttendance.setPeriod("1");
        findOaAttendance.getParams().put("overtime", "overtime");
        List<OaAttendance> oaAttendanceList =  oaAttendanceService.selectOaAttendanceList(findOaAttendance);
        if (StringUtils.isEmpty(oaAttendanceList)){
            return AjaxResult.cloud_602("未查询到加班数据");
        }
        OaAttendance attendance = oaAttendanceList.get(0);
        OaApply   oaApply  = new   OaApply();
        //如果是假日加班   起始时间从签到时间算起
        String oldDateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD,attendance.getDate())+" "+ finalOaConfig.getEndWorkTime()+":00";
        Long festival = calendarMap.get(attendance.getDate());
        if (festival == 1){
            OaAttendance oaAttendance = new  OaAttendance();
            oaAttendance.setDate(attendance.getDate());
            oaAttendance.setUserId(userId);
            oaAttendance.setPeriod("0");
            List<OaAttendance> oaAttendanceList1 =  oaAttendanceService.selectOaAttendanceList(oaAttendance);
            if (StringUtils.isNotEmpty(oaAttendanceList1)){
                oldDateStr = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,oaAttendanceList1.get(0).getPthTime());
            }
        }
        Date oldDate = DateUtils.dateTime(DateUtils.YYYY_MM_DD_HH_MM_SS,oldDateStr);//应该签退时间
        Date findDate = attendance.getPthTime();//打卡时间
        long interval = (findDate.getTime() - oldDate.getTime())/1000;
        if (interval > 1800){//加班时间超过半小时 算加班
            oaApply.setDate(attendance.getDate());
            oaApply.setDeptId(attendance.getDeptId());
            oaApply.setUserId(attendance.getUserId());
            oaApply.setUserName(attendance.getUserName());
            oaApply.setApplyType("overtime");
            oaApply.setStartDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,oldDate));
            oaApply.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,findDate));
            oaApply.setDuration(interval);
            oaApply.setDurationStr(DateUtils.getIntervalStr(interval));
        }else{
            if (StringUtils.isNull(oaApply)){
                return AjaxResult.cloud_602("未查询到加班数据");
            }
        }
        return AjaxResult.success(oaApply);
    }


    /**
     * 保存加班数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setApply")
    public AjaxResult getIsApply(@RequestBody OaApply oaApply,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        oaApply.setState("0");
        oaApply.setCreateBy(appUserView.getUser().getUserName());
        return toAjax(oaApplyService.insertOaApply(oaApply));
    }

    /**
     * 加班审核详情
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getApplyAuditing")
    public AjaxResult getApplyAuditing(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        Long id = appRequestView.getApplyId();
        OaApply oaApply = oaApplyService.selectOaApplyById(id);
        oaApply.setDurationStr(DateUtils.getIntervalStr(oaApply.getDuration()));
        OaAuditing oaAuditing = new OaAuditing();
        oaAuditing.setType("overtime");
        oaAuditing.setOutsideId(oaApply.getId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oaAuditing);
        oaApply.setAuditingList(auditingList);
        boolean isAuditor = false;
        if (!"0".equals(oaApply.getState())){
            isAuditor = false;
        }else {
            //判断当前用户是否允许可以审批
            List<String> codeList = new ArrayList<>();
            Long userId = appUserView.getUser().getUserId();
            List<Integer> postList = postService.selectPostListByUserId(userId);
            List<SysPost> postAllList = postService.selectPostList(null);
            postAllList.forEach(kv -> {
                if (postList.contains(kv.getPostId().intValue())) {
                    codeList.add(kv.getPostCode());
                }
            });
            if (!StringUtils.isEmpty(auditingList)) {
                isAuditor = FlowPath.isAuditing(codeList, "overtime", auditingList.get(auditingList.size() - 1).getSchedule());
            } else {
                isAuditor = FlowPath.isAuditing(codeList, "overtime", "");
            }
        }
        oaApply.setAuditor(isAuditor);
        return AjaxResult.success(oaApply);
    }


    /**
     * 加班审核
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setApplyAuditing")
    public AjaxResult setApplyAuditing(@RequestBody OaAuditing oaAuditing,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaAuditing oldOaAuditing = new OaAuditing();
        oldOaAuditing.setType("overtime");
        oldOaAuditing.setOutsideId(oaAuditing.getOutsideId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oldOaAuditing);
        int index = 0;
        if (!StringUtils.isEmpty(auditingList)){
            index = Arrays.binarySearch(FlowPath.OA_OVERTIME, auditingList.get(auditingList.size() - 1).getSchedule()) + 1;
        }
        oaAuditing.setSchedule(FlowPath.OA_OVERTIME[index]);
        oaAuditing.setType("overtime");
        oaAuditing.setAuditorTime(DateUtils.getNowDate());
        oaAuditing.setAuditorId(appUserView.getUser().getUserId());
        oaAuditing.setAuditorName(appUserView.getUser().getNickName());
        int rows = oaAuditingService.insertOaAuditing(oaAuditing);
        if (rows > 0){
            OaApply oaApply = oaApplyService.selectOaApplyById(oaAuditing.getOutsideId());
            if ("1".equals(oaAuditing.getState())){
                oaApply.setState("2");
                oaApplyService.updateOaApply(oaApply);
            }else{
                if ((FlowPath.OA_OVERTIME.length - 1) == index) {//最后一个流程
                    oaApply.setState("1");
                    oaApplyService.updateOaApply(oaApply);
                }
            }
        }
        return toAjax(rows);
    }
    /*****************************加班End***************************************************/
    /*****************************请假Start***************************************************/
    /**
     * 请假列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getLeaveList")
    public AjaxResult getLeaveList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaLeave oaLeave = new OaLeave();
        oaLeave.getParams().put("authority", DataScopeAspect.getDataScopeSql(appUserView.getUser()));
        List<OaLeave> list = oaLeaveService.selectOaLeaveList(oaLeave);
        return AjaxResult.success(list);
    }
    /**
     * 保存请假数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setLeave")
    public AjaxResult setLeave(@RequestBody OaLeave oaLeave,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        String duration = oaConfigService.getDuration(oaLeave.getStartDate(),oaLeave.getEndDate());
        if ("".equals(duration)){
            return AjaxResult.error("日期选择有误!");
        }
        oaLeave.setDuration(duration);
        oaLeave.setState("0");
        oaLeave.setUserName(appUserView.getUser().getNickName());
        oaLeave.setDeptId(appUserView.getUser().getDeptId());
        oaLeave.setUserId(appUserView.getUser().getUserId());
        oaLeave.setCreateBy(appUserView.getUser().getUserName());
        return  toAjax(oaLeaveService.insertOaLeave(oaLeave));
    }

    /**
     * 请假类型
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getLeaveType")
    public AjaxResult getLeaveType(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        List<ListStringView> list = new ArrayList<>();
        List<SysDictData> selectDictDataByType=dictTypeService.selectDictDataByType(ComUtil.CONFIG_LEAVE);
        selectDictDataByType.forEach(leave->{
            ListStringView kvView = new ListStringView();
            kvView.setKey(leave.getDictValue());
            kvView.setValue(leave.getDictLabel());
            list.add(kvView);
        });
        return AjaxResult.success(list);
    }

    /**
     * 请假审核详情
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getLeaveAuditing")
    public AjaxResult getLeaveAuditing(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        Long id = appRequestView.getLeaveId();
        OaLeave oaLeave = oaLeaveService.selectOaLeaveById(id);
        OaAuditing oaAuditing = new OaAuditing();
        oaAuditing.setType("leave");
        oaAuditing.setOutsideId(oaLeave.getId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oaAuditing);
        oaLeave.setAuditingList(auditingList);
        boolean isAuditor = false;
        if (!"0".equals(oaLeave.getState())){
            isAuditor = false;
        }else {
            //判断当前用户是否允许可以审批
            List<String> codeList = new ArrayList<>();
            Long userId = appUserView.getUser().getUserId();
            List<Integer> postList = postService.selectPostListByUserId(userId);
            List<SysPost> postAllList = postService.selectPostList(null);
            postAllList.forEach(kv -> {
                if (postList.contains(kv.getPostId().intValue())) {
                    codeList.add(kv.getPostCode());
                }
            });
            if (!StringUtils.isEmpty(auditingList)) {
                isAuditor = FlowPath.isAuditing(codeList, "leave", auditingList.get(auditingList.size() - 1).getSchedule());
            } else {
                isAuditor = FlowPath.isAuditing(codeList, "leave", "");
            }
        }
        oaLeave.setAuditor(isAuditor);
        //仅测试  上线删除
        if(SecurityUtils.isAdmin(appUserView.getUser().getUserId())){
            oaLeave.setAuditor(true);
        }
        return AjaxResult.success(oaLeave);
    }
    /**
     * 请假审核
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setLeaveAuditing")
    public AjaxResult setLeaveAuditing(@RequestBody OaAuditing oaAuditing,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaAuditing oldOaAuditing = new OaAuditing();
        oldOaAuditing.setType("leave");
        oldOaAuditing.setOutsideId(oaAuditing.getOutsideId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oldOaAuditing);
        int index = 0;
        if (!StringUtils.isEmpty(auditingList)){
            index = Arrays.binarySearch(FlowPath.OA_LEAVE, auditingList.get(auditingList.size() - 1).getSchedule()) + 1;
        }
        oaAuditing.setSchedule(FlowPath.OA_LEAVE[index]);
        oaAuditing.setType("leave");
        oaAuditing.setAuditorTime(DateUtils.getNowDate());
        oaAuditing.setAuditorId(appUserView.getUser().getUserId());
        oaAuditing.setAuditorName(appUserView.getUser().getNickName());
        int rows = oaAuditingService.insertOaAuditing(oaAuditing);
        if (rows > 0){
            OaLeave oaLeave = oaLeaveService.selectOaLeaveById(oaAuditing.getOutsideId());
            if ("1".equals(oaAuditing.getState())){
                oaLeave.setState("2");
                oaLeaveService.updateOaLeave(oaLeave);
            }else{
                if ((FlowPath.OA_LEAVE.length - 1) == index) {//最后一个流程
                    oaLeave.setState("1");
                    oaLeaveService.updateOaLeave(oaLeave);
                }
            }
        }
        return toAjax(rows);
    }
    /*****************************请假End***************************************************/
    /*****************************出差Start***************************************************/
    /**
     * 出差列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getMissionList")
    public AjaxResult getMissionList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaMission oaMission = new OaMission();
        oaMission.getParams().put("authority", DataScopeAspect.getDataScopeSql(appUserView.getUser()));
        List<OaMission> list = oaMissionService.selectOaMissionList(oaMission);
        return AjaxResult.success(list);
    }
    /**
     * 保存出差数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setMission")
    public AjaxResult setMission(@RequestBody OaMission oaMission,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        String duration = oaConfigService.getDuration(oaMission.getStartDate(),oaMission.getEndDate());
        if ("".equals(duration)){
            return AjaxResult.error("日期选择有误!");
        }
        oaMission.setDuration(duration);
        oaMission.setState("0");
        oaMission.setUserName(appUserView.getUser().getNickName());
        oaMission.setDeptId(appUserView.getUser().getDeptId());
        oaMission.setUserId(appUserView.getUser().getUserId());
        oaMission.setCreateBy(appUserView.getUser().getUserName());
        return  toAjax(oaMissionService.insertOaMission(oaMission));
    }

    /**
     * 出差审核详情
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getMissionAuditing")
    public AjaxResult getMissionAuditing(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        Long id = appRequestView.getMissionId();
        OaMission oaMission = oaMissionService.selectOaMissionById(id);
        OaAuditing oaAuditing = new OaAuditing();
        oaAuditing.setType("mission");
        oaAuditing.setOutsideId(oaMission.getId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oaAuditing);
        oaMission.setAuditingList(auditingList);
        boolean isAuditor = false;
        if (!"0".equals(oaMission.getState())){
            isAuditor = false;
        }else {
            //判断当前用户是否允许可以审批
            List<String> codeList = new ArrayList<>();
            Long userId = appUserView.getUser().getUserId();
            List<Integer> postList = postService.selectPostListByUserId(userId);
            List<SysPost> postAllList = postService.selectPostList(null);
            postAllList.forEach(kv -> {
                if (postList.contains(kv.getPostId().intValue())) {
                    codeList.add(kv.getPostCode());
                }
            });
            if (!StringUtils.isEmpty(auditingList)) {
                isAuditor = FlowPath.isAuditing(codeList, "mission", auditingList.get(auditingList.size() - 1).getSchedule());
            } else {
                isAuditor = FlowPath.isAuditing(codeList, "mission", "");
            }
        }
        oaMission.setAuditor(isAuditor);
        //仅测试  上线删除
        if(SecurityUtils.isAdmin(appUserView.getUser().getUserId())){
            oaMission.setAuditor(true);
        }
        return AjaxResult.success(oaMission);
    }
    /**
     * 出差审核
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setMissionAuditing")
    public AjaxResult setMissionAuditing(@RequestBody OaAuditing oaAuditing,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaAuditing oldOaAuditing = new OaAuditing();
        oldOaAuditing.setType("mission");
        oldOaAuditing.setOutsideId(oaAuditing.getOutsideId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oldOaAuditing);
        int index = 0;
        if (!StringUtils.isEmpty(auditingList)){
            index = Arrays.binarySearch(FlowPath.OA_MISSION, auditingList.get(auditingList.size() - 1).getSchedule()) + 1;
        }
        oaAuditing.setSchedule(FlowPath.OA_MISSION[index]);
        oaAuditing.setType("mission");
        oaAuditing.setAuditorTime(DateUtils.getNowDate());
        oaAuditing.setAuditorId(appUserView.getUser().getUserId());
        oaAuditing.setAuditorName(appUserView.getUser().getNickName());
        int rows = oaAuditingService.insertOaAuditing(oaAuditing);
        if (rows > 0){
            OaMission oaMission = oaMissionService.selectOaMissionById(oaAuditing.getOutsideId());
            if ("1".equals(oaAuditing.getState())){
                oaMission.setState("2");
                oaMissionService.updateOaMission(oaMission);
            }else{
                if ((FlowPath.OA_MISSION.length - 1) == index) {//最后一个流程
                    oaMission.setState("1");
                    oaMissionService.updateOaMission(oaMission);
                }
            }
        }
        return toAjax(rows);
    }
    /*****************************出差End***************************************************/
    /*****************************报销Start***************************************************/
    /**
     * 报销列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getExpenseList")
    public AjaxResult getExpenseList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaExpense oaExpense = new OaExpense();
        oaExpense.getParams().put("authority", DataScopeAspect.getDataScopeSql(appUserView.getUser()));
        List<OaExpense> list = oaExpenseService.selectOaExpenseList(oaExpense);
        return AjaxResult.success(list);
    }
    /**
     * 保存报销数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setExpense")
    public AjaxResult setExpense(@RequestBody OaExpense oaExpense,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        oaExpense.setState("0");
        oaExpense.setUserName(appUserView.getUser().getNickName());
        oaExpense.setDeptId(appUserView.getUser().getDeptId());
        oaExpense.setUserId(appUserView.getUser().getUserId());
        oaExpense.setCreateBy(appUserView.getUser().getUserName());
        return  toAjax(oaExpenseService.insertOaExpense(oaExpense));
    }
    /**
     * 报销类型
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getExpenseType")
    public AjaxResult getExpenseType(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        List<ListStringView> list = new ArrayList<>();
        List<SysDictData> selectDictDataByType=dictTypeService.selectDictDataByType(ComUtil.CONFIG_EXPENCE);
        selectDictDataByType.forEach(leave->{
            ListStringView kvView = new ListStringView();
            kvView.setKey(leave.getDictValue());
            kvView.setValue(leave.getDictLabel());
            list.add(kvView);
        });
        return AjaxResult.success(list);
    }

    /**
     * 报销审核详情
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getExpenseAuditing")
    public AjaxResult getExpenseAuditing(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        Long id = appRequestView.getExpenseId();
        OaExpense oaExpense = oaExpenseService.selectOaExpenseById(id);
        OaAuditing oaAuditing = new OaAuditing();
        oaAuditing.setType("expense");
        oaAuditing.setOutsideId(oaExpense.getId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oaAuditing);
        oaExpense.setAuditingList(auditingList);
        boolean isAuditor = false;
        if (!"0".equals(oaExpense.getState())){
            isAuditor = false;
        }else {
            //判断当前用户是否允许可以审批
            List<String> codeList = new ArrayList<>();
            Long userId = appUserView.getUser().getUserId();
            List<Integer> postList = postService.selectPostListByUserId(userId);
            List<SysPost> postAllList = postService.selectPostList(null);
            postAllList.forEach(kv -> {
                if (postList.contains(kv.getPostId().intValue())) {
                    codeList.add(kv.getPostCode());
                }
            });
            if (!StringUtils.isEmpty(auditingList)) {
                isAuditor = FlowPath.isAuditing(codeList, "expense", auditingList.get(auditingList.size() - 1).getSchedule());
            } else {
                isAuditor = FlowPath.isAuditing(codeList, "expense", "");
            }
        }
        oaExpense.setAuditor(isAuditor);
        //仅测试  上线删除
        if(SecurityUtils.isAdmin(appUserView.getUser().getUserId())){
            oaExpense.setAuditor(true);
        }
        return AjaxResult.success(oaExpense);
    }
    /**
     * 报销审核
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setExpenseAuditing")
    public AjaxResult setExpenseAuditing(@RequestBody OaAuditing oaAuditing,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaAuditing oldOaAuditing = new OaAuditing();
        oldOaAuditing.setType("expense");
        oldOaAuditing.setOutsideId(oaAuditing.getOutsideId());
        List<OaAuditing> auditingList = oaAuditingService.selectOaAuditingList(oldOaAuditing);
        int index = 0;
        if (!StringUtils.isEmpty(auditingList)){
            index = Arrays.binarySearch(FlowPath.OA_EXPENSE, auditingList.get(auditingList.size() - 1).getSchedule()) + 1;
        }
        oaAuditing.setSchedule(FlowPath.OA_EXPENSE[index]);
        oaAuditing.setType("expense");
        oaAuditing.setAuditorTime(DateUtils.getNowDate());
        oaAuditing.setAuditorId(appUserView.getUser().getUserId());
        oaAuditing.setAuditorName(appUserView.getUser().getNickName());
        int rows = oaAuditingService.insertOaAuditing(oaAuditing);
        if (rows > 0){
            OaExpense oaExpense = oaExpenseService.selectOaExpenseById(oaAuditing.getOutsideId());
            if ("1".equals(oaAuditing.getState())){
                oaExpense.setState("2");
                oaExpenseService.updateOaExpense(oaExpense);
            }else{
                if ((FlowPath.OA_EXPENSE.length - 1) == index) {//最后一个流程
                    oaExpense.setState("1");
                    oaExpenseService.updateOaExpense(oaExpense);
                }
            }
        }
        return toAjax(rows);
    }
    /*****************************报销End***************************************************/
    /**
     * 客户管理列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getClientList")
    public AjaxResult getClientList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        List<OaClient> list = oaClientService.selectOaClientList(null);
        return AjaxResult.success(list);
    }

    /**
     * 保存客户管理数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setClient")
    public AjaxResult setClient(@RequestBody OaClient oaClient,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        oaClient.setUserName(appUserView.getUser().getNickName());
        oaClient.setDeptId(appUserView.getUser().getDeptId());
        oaClient.setUserId(appUserView.getUser().getUserId());
        oaClient.setCreateBy(appUserView.getUser().getUserName());
        return  toAjax(oaClientService.insertOaClient(oaClient));
    }
    /**
     * 通讯录列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getAddressList")
    public AjaxResult getAddressList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        List<OaAddressView> list = new ArrayList<>();
        List<SysUser> sysUsersList =  userService.initUserList();
        Map<String,List<ListStringView>> phoneHt = new HashMap<>();
        sysUsersList.forEach(kv->{
              String phone = StringUtils.isHcNull(kv.getPhonenumber(), "");
              if (!"".equals(phone)){
                  List<ListStringView> alist = new ArrayList<>();
                  String nickName= kv.getNickName();
                  ListStringView listStringView = new ListStringView(nickName,phone);
                  String firstSpell = PingYinUtil.getFirstSpell(nickName.substring(0,1)).toUpperCase();
                  if (phoneHt.containsKey(firstSpell)){
                      alist = phoneHt.get(firstSpell);
                  }
                  alist.add(listStringView);
                  phoneHt.put(firstSpell,alist);

              }
        });
        phoneHt.forEach((k,v)->{
            OaAddressView  oaAddressView = new OaAddressView();
            oaAddressView.setLetter(k);
            oaAddressView.setContacts(v);
            list.add(oaAddressView);
        });
        list.sort(Comparator.comparing(OaAddressView::getLetter));
        return AjaxResult.success(list);
    }

    /*****************************合同Start***************************************************/
    /**
     * 合同列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getContractList")
    public AjaxResult getContractList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        OaContract oaContract =  new OaContract();
        oaContract.getParams().put("authority", DataScopeAspect.getDataScopeSql(appUserView.getUser()));
        List<OaContract> list = oaContractService.selectOaContractList(oaContract);
        return AjaxResult.success(list);
    }
    /**
     * 保存合同数据
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/setContract")
    public AjaxResult setContract(@RequestBody OaContract oaContract,@RequestParam(name = "token") String token) {
        //生成合同编号
        String identifier = StringUtils.isHcNull(oaContract.getIdentifier(),"");
        if ("".equals(identifier)){
            if ("销售合同".equals(oaContract.getType())){
                identifier = SerialNumberUtils.getSerialNumber(NumbereEnum.SYS_APPLETS_VENDITION_NUMBER);
            }else{
                identifier = SerialNumberUtils.getSerialNumber(NumbereEnum.SYS_APPLETS_PURCHASE_NUMBER);
            }
            //加横杆
            List<String> numberList= new ArrayList<>();
            numberList.add(identifier.substring(0,4));
            numberList.add(identifier.substring(4,12));
            numberList.add(identifier.substring(12));
            identifier = StringUtils.join(numberList, "-");
        }
        oaContract.setIdentifier(identifier);
        AppUserView appUserView = redisCache.getCacheObject(ComUtil.getOaCacheKey(token));
        oaContract.setUserName(appUserView.getUser().getNickName());
        oaContract.setDeptId(appUserView.getUser().getDeptId());
        oaContract.setUserId(appUserView.getUser().getUserId());
        oaContract.setCreateBy(appUserView.getUser().getUserName());
        return  toAjax(oaContractService.insertOaContract(oaContract));
    }
    /*****************************合同End***************************************************/
    /**
     * 通知公告列表
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getNoticeList")
    public AjaxResult getNoticeList(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        SysNotice notice = new SysNotice();
        notice.setStatus("0");
        List<SysNotice> list = noticeService.selectNoticeList(notice);
        return AjaxResult.success(list);
    }

    /**
     * 通知公告详情
     * @author cyt
     * @date 2021-06-23
     */
    @PostMapping("/getNoticeDetail")
    public AjaxResult getNoticeDetail(@RequestBody AppRequestView appRequestView,@RequestParam(name = "token") String token) {
        SysNotice notice = noticeService.selectNoticeById(appRequestView.getNoticeId());
        return AjaxResult.success(notice);
    }


    public static void main(String[] args) {

    }
}
